﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RegistCommon
{
    public class RegistFileHelper
    {
        static string path= System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
        public static string ComputerInfofile = path + "\\ComputerInfo.key";
        public static string RegistInfofile = path + "\\RegistInfo.key";
        public static void WriteRegistFile(string info)
        {
            RegistFileHelper.WriteFile(info, RegistFileHelper.RegistInfofile);
        }
        public static void WriteComputerInfoFile(string info)
        {
            RegistFileHelper.WriteFile(info, RegistFileHelper.ComputerInfofile);
        }
        public static string ReadRegistFile()
        {
            return RegistFileHelper.ReadFile(RegistFileHelper.RegistInfofile);
        }
        public static string ReadComputerInfoFile()
        {
            return RegistFileHelper.ReadFile(RegistFileHelper.ComputerInfofile);
        }
        public static bool ExistComputerInfofile()
        {
            return File.Exists(RegistFileHelper.ComputerInfofile);
        }
        public static bool ExistRegistInfofile()
        {
            return File.Exists(RegistFileHelper.RegistInfofile);
        }
        private static void WriteFile(string info, string fileName)
        {
            try
            {
                using (StreamWriter streamWriter = new StreamWriter(fileName, false))
                {
                    streamWriter.Write(info);
                    streamWriter.Close();
                }
            }
            catch (Exception var_1_2B)
            {
            }
        }
        private static string ReadFile(string fileName)
        {
            string result = string.Empty;
            try
            {
                using (StreamReader streamReader = new StreamReader(fileName))
                {
                    result = streamReader.ReadToEnd();
                    streamReader.Close();
                }
            }
            catch (Exception var_2_2F)
            {
            }
            return result;
        }
    }
}
